-- vim:set ft=lua: dofile(mg.script_name:gsub('[^\\/]*$','')..'util.lua') function AddReserve(onid,tsid,sid,eid,post) local r={onid=onid,tsid=tsid,sid=sid,eid=eid} local presetID=GetVarInt(post,'presetID',0,65534) if presetID then for i,v in ipairs(edcb.EnumRecPresetInfo()) do if v.id==presetID then r.recSetting=v.recSetting break end end end if r.recSetting then local useMargin=GetVarInt(post,'useDefMarginFlag')~=1 or nil r.recSetting={ batFilePath=r.recSetting.batFilePath, recFolderList=r.recSetting.recFolderList, partialRecFolder=r.recSetting.partialRecFolder, recMode=GetVarInt(post,'recEnabled')~=1 and 5 or GetVarInt(post,'recMode',0,4), noRecMode=GetVarInt(post,'recMode',0,4), tuijyuuFlag=GetVarInt(post,'tuijyuuFlag')==1, priority=GetVarInt(post,'priority',1,5), pittariFlag=GetVarInt(post,'pittariFlag')==1, suspendMode=GetVarInt(post,'suspendMode',0,4), rebootFlag=GetVarInt(post,'rebootFlag')==1, startMargin=useMargin and GetVarInt(post,'startMargin',-6*3600,6*3600), endMargin=useMargin and GetVarInt(post,'endMargin',-6*3600,6*3600), serviceMode=GetVarInt(post,'serviceMode')==1 and 0 or 1+16*(GetVarInt(post,'serviceMode_1',0,1) or 0)+32*(GetVarInt(post,'serviceMode_2',0,1) or 0), continueRecFlag=GetVarInt(post,'continueRecFlag')==1, tunerID=GetVarInt(post,'tunerID'), partialRecFlag=GetVarInt(post,'partialRecFlag',0,1) or 0 } local ev=edcb.SearchEpg(onid,tsid,sid,eid) if ev and ev.startTime and ev.durationSecond and r.recSetting.recMode and r.recSetting.priority and r.recSetting.suspendMode and (not useMargin or r.recSetting.startMargin and r.recSetting.endMargin) and r.recSetting.tunerID then r.title=ev.shortInfo and ev.shortInfo.event_name or '' r.startTime=ev.startTime r.startTimeEpg=ev.startTime r.durationSecond=ev.durationSecond r.stationName='' for i,v in ipairs(edcb.GetServiceList() or {}) do if v.onid==onid and v.tsid==tsid and v.sid==sid then r.stationName=v.service_name break end end return edcb.AddReserveData(r) end end return false end ct=CreateContentBuilder(GZIP_THRESHOLD_BYTE) ct:Append([=[

# 番組詳細

]=]) onid,tsid,sid,eid=(mg.get_var(mg.request_info.query_string,'id') or ''):match('^(%d?%d?%d?%d?%d)%-(%d?%d?%d?%d?%d)%-(%d?%d?%d?%d?%d)%-(%d?%d?%d?%d?%d)$') onid=tonumber(onid) or 0 tsid=tonumber(tsid) or 0 sid=tonumber(sid) or 0 eid=tonumber(eid) or 0 presetID=GetVarInt(mg.request_info.query_string,'presetID') or 65535 post=AssertPost() if post then if mg.get_var(post,'addchg') then ct:Append('
'..(AddReserve(onid,tsid,sid,eid,post) and '予約を追加しました' or '入力値不正')..'
\n') end end r=nil edcb.htmlEscape=15 for i,v in ipairs(edcb.GetReserveData()) do if v.onid==onid and v.tsid==tsid and v.sid==sid and v.eid==eid then r=v break end end if not r and presetID==65535 then presetID=0 end ct:Append('

\n' ..'
番組情報
  \n'..ConvertEpgInfoText2(onid,tsid,sid,eid):gsub('\r?\n','
  \n')..'
\n') if r then dur=r.startTime.hour*3600+r.startTime.min*60+r.startTime.sec+r.durationSecond ct:Append('
プログラム予約化（プログラム予約化は元に戻せません。番組を特定できなくなるため追従もできません。）
  \n' ..'
  \n' ..'\n' ..'予約日時: //\n:: ～\n::
  \n' ..'
\n') end ct:Append('
プリセット
  \n' ..'
  ' ..'
\n' ..'
録画設定
  \n' ..'
  \n' ..'\n' ..'\n' ..RecSettingTemplate(rs)..'
\n') if r then ct:Append('
-
  \n' ..'
  \n' ..'\n' ..'\n' ..'
\n') end ct:Append([=[

]=]) ct:Finish() mg.write(ct:Pop(Response(200,'text/html','utf-8',ct.len)..(ct.gzip and 'Content-Encoding: gzip\r\n' or '')..'\r\n'))